<?php

/**
 * Mapping table [cdb_threads]
 *
 * @category   app_M
 * @package    app_M
 * @author     
 * @copyright  Copyright (c)
 * @license
 */
class Threads extends Zend_Db_Table
{
    /**
     * The table name.
     *
     * @var string
     */
	protected function _setup()
	{
		$config = Zend_Registry::get('config');
		$this->_name = $config->db->config->prcode.'threads';
		$this->_request = new Zend_Controller_Request_Http();
		parent::_setup();
	}
	/**
      *论坛帖子列表,并且分页处理
      */
	public function category_thread($_page,$cat,$nums=15,$link='?')
	{
       $where = $this->getAdapter()->quoteInto('fid = ?',$cat);
	   $total = $this->fetchAll($where)->count();
	   $pager = new Pager($total,$nums,$_page);
	   $order = 'dateline';
       $count = $nums;
       $offset = $pager->_offset();
	   $rowset = $this->fetchAll($where, $order, $count, $offset);
       foreach ($rowset as $row)
		{
			$row->dateline = date('Y-m-d',$row->dateline);
		}
       $this->pagurl= $pager->num_link($link);
	   return $rowset->toArray();
	}
}